package com.sharecode.stock.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sharecode.stock.annotation.AdminAnnotation;
import com.sharecode.stock.service.StockStrategyService;
import com.sharecode.stock.thread.ThreadLocalUtils;
import com.sharecode.stock.vo.stock.StockStrategy;

@RestController
@RequestMapping("/api")
public class StockController {
	@Autowired
	private StockStrategyService stockStrategyService;

	@GetMapping("strategy")
	public Object strategy() {
		return stockStrategyService.findPage(ThreadLocalUtils.getParamData());
	}

	/**
	 * 推荐
	 * 
	 * @return
	 */
	@GetMapping("rm")
	public Object rm() {
		return stockStrategyService.findRm();
	}

	@PutMapping("strategy")
	@AdminAnnotation
	public void update(StockStrategy strategy) {
		stockStrategyService.update(strategy.getId(), strategy.getStar());
	}
}
